home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group01b.txt
/
000140_icon-group-sender_Mon Sep 3 19:28:47 2001.msg
< prev
next >
Wrap
Internet Message Format
|
2002-01-03
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id f842RCE25262
for icon-group-addresses; Mon, 3 Sep 2001 19:27:12 -0700 (MST)
Message-Id: <200109040227.f842RCE25262@baskerville.CS.Arizona.EDU>
Date: Mon, 03 Sep 2001 11:07:37 +1100
From: dodod <dodo@hotmail.com>
X-Accept-Language: en
X-Newsgroups: comp.lang.icon
Subject: Re: join
To: icon-group@cs.arizona.edu
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1712
thanks
Andrew Hamm wrote:
>
> dodod wrote in message <3B8C3D59.AA150BB8@hotmail.com>...
> >hello
> >i would like to write a program to emulate
> >unix join command but i do not know how to start
> >can you give me a hint or an example ?
> >
> possibly start by coding a function which can be used in a coroutine. This
> function's job is to suspend with a line from a text file. When used in a
> coroutine, it could be activated with a parameter which tells it to either
> yield the current line or the next line. In other words, the coroutine could
> be used to provide look-ahead or actual read of next line.
>
> Then, start two separate coroutines using this function, applied to the two
> different files. Your main loop could peek at each line, and if it matches,
> perform the join otherwise move on. Since the rule in UNIX join is that the
> lines must be presented in "increasing collating sequence" (ie sorted on the
> key field) then depending on the relative << == or >> of the key fields on
> the line, you activate one or the other coroutines to read the next line
> from either or both files.
>
> Hmm - now that I think about it, I dont think the coroutine function needs
> to offer look-ahead, and therefore doesn't need the activation flag.
> Activate both coroutines prior to the start of your loop, store the results
> in a local buffer, and ask for the next row as needed as you progress.
>
> I suppose it could also be programmed without the use of coroutines, but
> where's the fun in that?
>
> --
> Space Corps Directive #349
> Any officer found to have been slaughtered and replaced by a shape-changing
> chameleonic life form shall forfeit all pension rights.
> -- Red Dwarf